package ui;

// Ce package contient les elements permettant de gerer l'interface graphique
import javax.microedition.lcdui.*;

import javax.*;

public class EcranListeRagots
{
    private Command commandExit;
    private Command commandBack;
    private Command commandAfficher;
    private List ecranRagots;
    
    public EcranListeRagots(gen.Controleur cont)
    {
        this.ecranRagots = new List("RAGOTRON", List.IMPLICIT);


        //Commandes

        // creation d'un bouton pour sortir du programme
        this.commandExit = new Command("Exit", Command.SCREEN,1);
        this.commandBack = new Command("Voltar", Command.SCREEN, 1);
        this.commandAfficher = new Command("Afficher", Command.SCREEN, 1);
        this.ecranRagots.setSelectCommand(commandAfficher);


        // creation d'un champ de texte
        //this.dernierRagot = new StringItem("Dernier ragot : ","Editez ce message !",25,TextField.ANY);

        // ajout des composants au formulaire
        this.ecranRagots.addCommand(commandExit);
        this.ecranRagots.addCommand(commandBack);
       // this.ecranRagots.addCommand(commandAfficher);

        this.ecranRagots.setCommandListener(cont);
    }
    public Command getCommandExit()
    {
        return this.commandExit;
    }

    public Command getCommandBack()
    {
        return this.commandBack;
    }

    public Command getCommandAfficher()
    {
        return this.commandAfficher;
    }

    public String getMessage()
    {
        int index = this.ecranRagots.getSelectedIndex();
        String s = this.ecranRagots.getString(index);
        return s;
    }

    public List getScreen()
    {
        return this.ecranRagots;
    }

}
